const path = require('path');
const webpack = require('webpack');

function resolve(dir) {
	return path.join(__dirname, dir);
}

module.exports = {
	outputDir: 'dist',
	assetsDir: './static',
	indexPath: './index.html',
	productionSourceMap: false,
	devServer: {
		https: false,
		port: 8189,
		proxy: {
			'/mgr': {
				target: 'http://10.10.44.101:5002', //开发环境-三个节点
				// target: 'http://10.244.4.58:9221', //开发环境-三个节点
				// target: 'http://172.18.33.182:9302',
				// target: 'http://172.18.30.5:5002',
				// target: 'http://10.10.44.161:9221',
				// target: 'http://10.10.44.101:5002',
				// target: 'http://10.10.18.27:9221', //晓峰
				// target: 'http://47.106.221.58:5002',
				// target: 'http://10.10.18.33:9221', //炳忠
				// target: 'http://10.10.18.65:9221', //安民
				// target: 'http://10.10.18.32:9221', //刘伟祥
				// target: 'http://10.10.44.169:9221', // 世鸿
				// target: 'https://mgr.k8s.yidianting.com.cn', //测试环境
				changeOrigin: true,
				pathRewrite: {
					'^/mgr': '/mgr'
				}
			},
			'/park-config-service': {
				changeOrigin: true,
				target: 'http://10.10.44.161:8763', //刘伟祥
				pathRewrite: {
					'^/park-config-service': '/park-config-service'
				}
			},
			// '/addOperatorPark': {
			//   target: 'http://10.10.18.32:9031',
			//   changeOrigin: true,
			//   pathRewrite: {
			//     '^/addOperatorPark': '/addOperatorPark'
			//   }
			// },
			'/zbcloud-ws': {
				target: 'wss://zbcloud.yidianting.com.cn',
				changeOrigin: true,
				ws: true,
				pathRewrite: {
					'^/zbcloud-ws': '/'
				}
			},
			'/zbcloud': {
				target: 'https://zbcloud.yidianting.com.cn',
				changeOrigin: true,
				pathRewrite: {
					'^/zbcloud': '/'
				}
			}
		}
	},
	lintOnSave: false,
	chainWebpack: config => {
		config.resolve.alias
			.set('vue$', 'vue/dist/vue.common.js')
			.set('@', resolve('src'))
			.set('src', resolve('src'))
			.set('assets', resolve('src/assets'))
			.set('@components', resolve('src/components'))
			.set('@mixins', resolve('src/mixins'));
	},
	configureWebpack: {
		plugins: [
			new webpack.ProvidePlugin({
				$: 'jquery',
				jQuery: 'jquery',
				'windows.jQuery': 'jquery',
				moment: 'moment'
			})
		]
	},
	pluginOptions: {
		dll: {
			entry: {
				vendorNameOne: ['vue', 'axios', 'qs', 'vue-router', 'vuex'],
				vendorNameTwo: ['moment', 'jquery', 'vue-resource', 'echarts', 'crypto-js']
			},
			output: path.join(__dirname, './public/dll'),
			inject: true,
			cacheFilePath: path.resolve(__dirname, './public'),
			open: process.env.NODE_ENV === 'production'
		}
	}
};
